<?php

namespace app\mp\controller;

use app\common\entity\Result;
use app\common\service\VideoService;
use app\Request;
use app\wxapp\service\TopicService;

class Topic extends Base
{
    public function getTopic(Request $request)
    {
        $id = $request->param('id');
        $service = new TopicService();
        $data = $service->getOne($id);
        foreach ($data['sub'] as &$row) {
            $row['progress'] = VideoService::getProgress($row['id'], $this->user['id']);
        }
        return Result::success($data);
    }
}